/***
 *   @title qz
 *   @description <description class purpose>
 *   @author yichen
 *   @version 1.0.0
 *   @create 2023/10/25 0025
 **/
package io.gitee.wokaixin.yunque.message.example;

import io.gitee.wokaixin.yunque.driver.*;
import io.gitee.wokaixin.yunque.message.service.*;
import org.springframework.beans.factory.annotation.*;
import org.springframework.stereotype.*;

import javax.annotation.*;

@Component
public class MessageI extends MessageService {
    @Value("${message.driverType}")
    private  String driverType;
    @Autowired
    private  KafkaConfigI kafkaConfig;
    @Autowired
    private  RedisConfigI redisConfig;
    @PostConstruct
    public void initField(){
        this.getMessageService();
    }
    public void getMessageService() {
        DriverFactory driverFactory = new DriverFactory();
        if (driverType.equals("kafka")) {
            driverFactory.setDriverFactory(kafkaConfig);
        } else {
            driverFactory.setDriverFactory(redisConfig);
        }
        this.setDriverFactory(driverFactory);
        this.setDriverType( driverType);
    }
}
